//
//  UIButton+Extension.swift
//  DDPictureSelectorTest
//
//  Created by dqw on 15/8/7.
//  Copyright © 2015年 itcast. All rights reserved.
//

import UIKit

extension UIButton {
    
    convenience init(imageName: String?) {
        self.init()

        setImage(imageName)
        
        }
    
     func setImage(name: String?) {
        
        setImage(UIImage(named: name!), forState: UIControlState.Normal)
        setImage(UIImage(named: name! + "_highlighted"), forState: UIControlState.Highlighted)
        contentEdgeInsets = UIEdgeInsets(top: 5, left: 5, bottom: 5, right: 5)
        imageView?.contentMode = UIViewContentMode.ScaleAspectFill
        sizeToFit()
    }
}
